//系统逻辑及业务相关通用函数库

import Cookies from "js-cookie";
import config from "@/config";
import { forEach, hasOneOf } from "@/libs/tools";

export const TOKEN_KEY = "token";

//通用 sessionStorage string/jsonString
export const getSessionStore = key => {
  let str = sessionStorage.getItem(key);
  return str;
};

export const setSessionStore = (key, value) => {
  sessionStorage.setItem(key, value);
};

export const getSessionObjStore = key => {
  let str = sessionStorage.getItem(key);
  if (str) {
    return JSON.parse(str);
  } else {
    return null;
  }
};

export const setSessionObjStore = (key, value) => {
  sessionStorage.setItem(key, JSON.stringify(value));
};

//通用 localStorage string/jsonString
export const getLocalStore = key => {
  let str = localStorage.getItem(key);
  return str;
};

export const setLocalStore = (key, value) => {
  localStorage.setItem(key, value);
};

export const getLocalObjStore = key => {
  let str = localStorage.getItem(key);
  if (str) {
    return JSON.parse(str);
  } else {
    return null;
  }
};

export const setLocalObjStore = (key, value) => {
  localStorage.setItem(key, JSON.stringify(value));
};
